using UnityEngine;

public class StorageManager {
    private static StorageManager instance;
    public static StorageManager Instance {
        get {
            if(instance == null) {
                instance = new StorageManager();
            }
            return instance;
        }
    }

    public void UpdateDataToStore(string key,PlayerData data) {
        string jsonData = JsonUtility.ToJson(data);
        PlayerPrefs.SetString(key,jsonData);
        PlayerPrefs.Save();
    }

    public PlayerData GetDataFromStore(string key) {
        if(!PlayerPrefs.HasKey(key)) return null;
        string jsonData = PlayerPrefs.GetString(key);
        return JsonUtility.FromJson<PlayerData>(jsonData);
    }
}